package com.tzbank.common.controller;

import com.tzbank.common.service.TestService;
import com.tzbank.utils.ResultCode;
import com.tzbank.utils.ResultUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@Slf4j
public class TestController {

    @Autowired
    private RedisTemplate redisTemplate;

    @Autowired
    private SqlSession sqlSession;

    @Autowired
    private TestService testService;

    @Autowired
    private Environment environment;

    @RequestMapping("/test")
    public Map<String,Object> test(){

        testService.testKafka();
//        System.out.print("clss:"+AuthUserMapper.class.getName());
//        try{
//            throw new BusinessException("转账","2000","金额太小");
//        }catch (BusinessException e){
//            System.out.print(e.getMessage());
//        }
//       log.info("日志测试========================");
        return ResultUtil.resultMap("测试",ResultCode.RESULT_CODE_SUCCESS.code(),null);
    }

    @RequestMapping("/test2")
    public Map<String,Object> event(){
        String aa = environment.getProperty("aa",String.class);
        return ResultUtil.resultMap("测试",ResultCode.RESULT_CODE_SUCCESS.code(),aa);
    }
}
